<template>
  <div class="nav-icon-item" :class="{ active: isActive }" @click="handleClick">
    <div class="icon-wrapper">
      <slot></slot>
    </div>
    <div class="label">{{ label }}</div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue'

const props = defineProps({
  label: {
    type: String,
    required: true
  },
  index: {
    type: String,
    required: true
  },
  isActive: {
    type: Boolean,
    default: false
  }
})

const emit = defineEmits(['click'])

const handleClick = () => {
  emit('click', props.index)
}
</script>

<style scoped>
.nav-icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 70px;
  width: 100%;
  padding: 8px 0;
  cursor: pointer;
  color: white;
  position: relative;
  box-sizing: border-box;
  transition: background-color 0.3s ease;
}

.nav-icon-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-icon-item.active {
  background-color: rgba(255, 255, 255, 0.15);
}

.nav-icon-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 50%;
  background-color: #ffffff;
  border-radius: 0 3px 3px 0;
}

.icon-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 5px;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.icon-wrapper :deep(.el-icon) {
  font-size: 22px;
  color: white;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.label {
  font-size: 12px;
  text-align: center;
  line-height: 1.2;
  color: white;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
  box-sizing: border-box;
}
</style>